home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-04 | 3.0 KB | 114 lines | [TEXT/KAHL] |
- /********************************************************* DEFINITION
- DATE: 9/28/93
- AUTHOR: Eric R. Rosé
-
- CLASS: CPPDialogText
-
- SUPERCLASS: CPPFilterText
-
- This C++ class manages a textedit area with no scrollbars and
- a length limit of 255 characters.
-
- ********************************************************************/
-
- #include <CPPDialogText.h>
-
- /*-----------------------------------------------------------------*/
- /*------------------------ PUBLIC METHODS -------------------------*/
- /*-----------------------------------------------------------------*/
-
- CPPDialogText::CPPDialogText (CPPWindow *OurWindow,
- Rect *itsBounds,
- StringPtr defaultString,
- int maxLength,
- int Font,
- int FSize) :
- CPPFilterText (OurWindow, itsBounds, itsBounds,
- maxLength, block, (int)none, FALSE,
- FALSE, Font, FSize)
- {
- if (defaultString)
- SetToString (defaultString);
-
- SetFilterString ("\p\r"); // no returns allowed
- }
-
- /*-----------------------------------------------------------------*/
-
- CPPDialogText::CPPDialogText (CPPWindow *OurWindow,
- Rect *itsBounds,
- short StringID,
- int maxLength,
- int Font,
- int FSize) :
- CPPFilterText (OurWindow, itsBounds, itsBounds,
- maxLength, pass, (int)all, FALSE,
- FALSE, Font, FSize)
- {
- StringHandle tempString = GetString (StringID);
-
- if (tempString)
- {
- SetTextHandle((Handle)tempString,
- GetHandleSize((Handle)tempString),
- TRUE);
- ReleaseResource((Handle)tempString);
- }
- }
-
- /*-----------------------------------------------------------------*/
-
- CPPDialogText::~CPPDialogText (void)
- {
- }
-
- /*-----------------------------------------------------------------*/
-
- char *CPPDialogText::ClassName (void)
- {
- return "CPPDialogText";
- }
-
- /*-----------------------------------------------------------------*/
-
- void CPPDialogText::TargetHilite (Boolean makeTarget)
- /* change the hiliteed state of the object */
- /* if the text object is becoming the target, select all its text */
- {
- CPPFilterText::TargetHilite(makeTarget);
-
- if (this->IsActive())
- DoSelectAll();
- }
-
- /*-----------------------------------------------------------------*/
-
- StringPtr CPPDialogText::GetAsString (void)
- /* allocate and return as a stringptr a copy of the text */
- /* in the text edit area */
- {
- CharsHandle tempHandle = GetTheText();
- short textLen = GetHandleSize(tempHandle);
- StringPtr tempPtr;
-
- if (tempHandle && textLen)
- {
- tempPtr = (StringPtr)NewPtr(textLen + 1);
- if (tempPtr)
- {
- BlockMove (*tempHandle, tempPtr+1, textLen);
- *tempPtr = textLen;
- }
- }
- return tempPtr;
- }
-
- /*-----------------------------------------------------------------*/
-
- void CPPDialogText::SetToString (StringPtr newString)
- /* set the dialog text object's contents to the passed-in string */
- {
- if (newString)
- SetTextPtr ((Ptr)(newString+1), *newString, TRUE);
- }
-